import { http } from '@/utils/http'
import { AppThunk } from '../index'
import { Article } from '@/pages/Publish'
export const publishArticle = (payload?: { draft: boolean; formData: Article }): AppThunk => {
  return async (dispatch, getState) => {
    if (!payload) return
    const { draft, formData } = payload
    await http.post('/mp/articles/?draft=' + draft, formData)
    // dispatch()
  }
}
export const eidArticle = (payload?: { id: string; draft: boolean; formData: Article }): AppThunk => {
  return async (dispatch, getState) => {
    if (!payload) return
    const { id, draft, formData } = payload
    await http.put('/mp/articles/' + id + '/?draft=' + draft, formData)
    // dispatch()
  }
}

